
#ifndef __world_cameraH__
#define __world_cameraH__

#include "camera.h"
#include "physics.h"

namespace WtfEngine
{
	/**
	 * Defines a camera which is part of the physical world, and behaves
	 * according to the laws of physics. Camera can be set to track objects,
	 * giving a third person view.
	 **/
	class WorldCamera : public virtual ICamera, public Physical
	{
		Physical::tRef		mrTrackedObject;
		Constraint::tRef	mrTrackingConstraint;
		
		public:
			WorldCamera(const tVector& pos, const tVector& dir,
						const tVector& up);
		
			void EnterPerspective(const IScreen::tRef& pScreen);
			void LeavePerspective();
		
			tVector getPosition() {
				return Physical::getPosition();
			};
			tVector getDirection() {
				return Physical::getOrientation() * tVector(0,0,-1);
			};
			void getDirection(tVector& dir, tVector& up) {
				Orientation3D ori(Physical::getOrientation());
				dir = ori * tVector(0,0,-1);
				up = ori * tVector(0,1,0);
			};
			
			void TrackObject(const WorldObject::tRef& rObj);
		
			GC_AUTOSIZE(WorldCamera);
	};
};


#endif
